#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>

int main(int argc, char const* argv[])
{
    pid_t pid;

    if ((pid = fork()) == 0)
    {
        printf("I am in child\n");
        printf("my pid is %d\n", getpid());
        printf("my group is %d\n", getpgid(0));
        printf("my session id is %d\n", getsid(0));
        setsid();
        printf("my group is %d\n",getpgid(0));
        printf("my session id is %d\n", getsid(0));
        printf("I will sleep 3 sec, and u can't ctrl+c me," 
            " because i don't hava a control terminal, and u can ps -e, "
            " my control terminal is '?'\n");
        sleep(3);
        printf("look, I am back ^^!\n");
    }

    waitpid(pid, NULL, 0);

    return 0;
}
